package com.jason.www.commons;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import java.util.Properties;

public class PropertyConfigurer extends PropertyPlaceholderConfigurer {

    private Properties props;

    @Override
    protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
            throws BeansException {
        super.processProperties(beanFactoryToProcess, props);
        this.props = props;
    }

    public String getProperty(String key) {
        return this.props.getProperty(key);
    }

    public String getProperty(String key, String defaultValue) {
        return this.props.getProperty(key, defaultValue);
    }

    public Object setProperty(String key, String value) {
        return this.props.setProperty(key, value);
    }

    public String getOverhttps() {
        return getProperty("pay.overhttps", "N");
    }

    public String getRequestUrl() {
        return getProperty("pay.request_url");
    }

    public String getNotifyUrl() {
        return getProperty("pay.notify_url");
    }

    public String getReturnUrl() {
        return getProperty("pay.return_url");
    }

    public String getAlipayAppId() {
        return getProperty("pay.alipay.appId");
    }

    public String getAlipayPrivateKey() {
        return getProperty("pay.alipay.private_key");
    }

    public String getAlipayPublicKey() {
        return getProperty("pay.alipay.public_key");
    }

    public String getAlipayPartner() {
        return getProperty("pay.alipay.partner");
    }

    public String getAlipayNotifyUrl() {
        return getProperty("pay.alipay.notify_url");
    }

    public String getUnionpayMerid() {
        return getProperty("pay.unionpay.merId");
    }

    public String getUnionpayNotifyUrl() {
        return getProperty("pay.unionpay.notify_url");
    }

    public String getWXpayAppId() {
        return getProperty("pay.wxpay.appId");
    }

    public String getWXpayOpenId() {
        return getProperty("pay.wxpay.openId");
    }

    public String getWXpayPartner() {
        return getProperty("pay.wxpay.partner");
    }

    public String getWXpayPrivateKey() {
        return getProperty("pay.wxpay.private_key");
    }

    public String getWXpayNotifyUrl() {
        return getProperty("pay.wxpay.notify_url");
    }
}